<?php
/**
 * Implement command WNavigator/delPage
 * <pre>
 * Arguments: 
 * 1. path (string, mandatory) 
 *    Path to the page to be deleted.
 * Result:
 * See command WNavigator/getPage   
 * </pre>
 * @package WNavigator
 * 
 */
require_once 'WKernel/Command/Abstract.php';
class WN_Cmd_delPage extends WK_Command_Abstract {
	public function __construct(){
		parent::__construct();
		$this->params['save'] = false;
	}
	public function exec(){
		$nav  = WK_Application::getComponent('WNavigator');
		$page = $nav->getMap()->delPage($this->params['path']);
		if(!empty($page)) {
			if($this->params['save'])	$nav->saveMap();
			$this->result = $page->toData();
		}
		else {
			throw WK_Application::getException(404, 'Page not found!');
		}
	}	
}